// pages/music/music.js
Page({
  data: {
  },
  onLoad: async function (options) {
    var module = await import("../../utils/util");
    //获取当前城市
    var position = await module.getPosition.getLocal();
    var {latitude,longitude} = position;
    var countryRes = await module.getPosition.getCountry(latitude,longitude);
    var {city} = countryRes.data.result.address_component;
    city = city.slice(0,2);
    this.setData({city});
    //得到所有页面http请求的结果
    var bannerRes = await module.musicHttp.getBanner();
    var hotRes = await module.musicHttp.getHotMusic();
    var newestRes = await module.musicHttp.getNewest();
    var djRes = await module.musicHttp.getDjProgram();
    this.setData({
      banners:bannerRes.data.banners,
      playlists:hotRes.data.playlists.slice(0,3),
      newest:newestRes.data.albums.slice(0,3),
      dj:djRes.data.result.slice(0,3)
    });
  },
  navToSearch(){
    wx.navigateTo({
      url: '/pages/search/search',
    })
  }
})